package com.cx.factoryMethod.constant;

import com.cx.factoryMethod.api.GiveAward;
import com.cx.factoryMethod.api.impl.CouponAwardImpl;
import com.cx.factoryMethod.api.impl.GoodsAwardImpl;
import com.cx.factoryMethod.api.impl.IQiYiAwardImpl;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * @Author:cxy
 * @Date:2022/3/21 20:57
 */
@AllArgsConstructor
@NoArgsConstructor
@Getter
public enum AwardEnum {

    IQiYi_AWARD(1, IQiYiAwardImpl.class),
    COUPON_AWARD(2, CouponAwardImpl.class),
    GOODS_AWARD(3, GoodsAwardImpl.class);

    private Integer typeId;

    private Class<? extends GiveAward> awardClass;

    public static Class<? extends GiveAward> valueOf(int typeId){

        for (AwardEnum value : values()) {
            if (value.getTypeId() == typeId){
                return value.getAwardClass();
            }
        }
        return null;
    }
}
